package com.disease.chronic.Controller;

import com.disease.chronic.Global.Result;
import com.disease.chronic.Service.FamilyService;
import com.disease.chronic.pojo.Family;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/family")
public class FamilyController {


    @Autowired
    FamilyService familyService;

    @GetMapping("/get")
    public @ResponseBody Result getFamily(@RequestParam("username") String username){
        return familyService.getFamily(username);
    }

    @PostMapping("/add")
    public @ResponseBody Result addFamily(@RequestBody Family family){
        return familyService.addFamily(family);
    }
    @GetMapping("/delete")
    public @ResponseBody Result deleteFamily(@RequestParam("phone") String phone){
        System.out.println(phone);
        return familyService.deleteByPhone(phone);
    }
}
